import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Video } from '../video/video.entity';
import { MediaCheck } from './mediaCheck.entity';

@Injectable()
export class MediaCheckService {
  constructor(
    @InjectRepository(MediaCheck)
    private repository: Repository<MediaCheck>,
    @InjectRepository(Video)
    private videoRepository: Repository<Video>,
  ) {}

  findAll(): Promise<MediaCheck[]> {
    return this.repository.find();
  }

  findOne(id: any): Promise<MediaCheck> {
    return this.repository.findOne(id);
  }

  async remove(id: number): Promise<void> {
    await this.repository.delete(id);
  }

  async create(data: MediaCheck): Promise<void> {
    await this.repository.save(data);
  }

  async updateVideoCheckText_By_Trace_id(trace_id: string,check_text: number): Promise<void> {
    await this.videoRepository.update({trace_id:trace_id},{check_text:check_text,check_text_time:new Date()})
  }
  
  async updateVideoCheckText_By_id(video_id: number,check_text: number): Promise<void> {
    await this.videoRepository.update({id:video_id},{check_text:check_text,check_text_time:new Date()})
  }
  
}
